home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-MIPS / SGIARCS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  12KB  |  353 lines

  1. /* $Id: sgiarcs.h,v 1.2 1998/07/08 16:01:57 ralf Exp $
  2.  *
  3.  * SGI ARCS firmware interface defines.
  4.  *
  5.  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  6.  */
  7.  
  8. #ifndef _MIPS_SGIARCS_H
  9. #define _MIPS_SGIARCS_H
  10.  
  11. /* Various ARCS error codes. */
  12. #define PROM_ESUCCESS                   0x00
  13. #define PROM_E2BIG                      0x01
  14. #define PROM_EACCESS                    0x02
  15. #define PROM_EAGAIN                     0x03
  16. #define PROM_EBADF                      0x04
  17. #define PROM_EBUSY                      0x05
  18. #define PROM_EFAULT                     0x06
  19. #define PROM_EINVAL                     0x07
  20. #define PROM_EIO                        0x08
  21. #define PROM_EISDIR                     0x09
  22. #define PROM_EMFILE                     0x0a
  23. #define PROM_EMLINK                     0x0b
  24. #define PROM_ENAMETOOLONG               0x0c
  25. #define PROM_ENODEV                     0x0d
  26. #define PROM_ENOENT                     0x0e
  27. #define PROM_ENOEXEC                    0x0f
  28. #define PROM_ENOMEM                     0x10
  29. #define PROM_ENOSPC                     0x11
  30. #define PROM_ENOTDIR                    0x12
  31. #define PROM_ENOTTY                     0x13
  32. #define PROM_ENXIO                      0x14
  33. #define PROM_EROFS                      0x15
  34. /* SGI ARCS specific errno's. */
  35. #define PROM_EADDRNOTAVAIL              0x1f
  36. #define PROM_ETIMEDOUT                  0x20
  37. #define PROM_ECONNABORTED               0x21
  38. #define PROM_ENOCONNECT                 0x22
  39.  
  40. /* Device classes, types, and identifiers for prom
  41.  * device inventory queries.
  42.  */
  43. enum linux_devclass {
  44.     system, processor, cache, adapter, controller, peripheral, memory
  45. };
  46.  
  47. enum linux_devtypes {
  48.     /* Generic stuff. */
  49.     Arc, Cpu, Fpu,
  50.  
  51.     /* Primary insn and data caches. */
  52.     picache, pdcache,
  53.  
  54.     /* Secondary insn, data, and combined caches. */
  55.     sicache, sdcache, sccache,
  56.  
  57.     memdev, eisa_adapter, tc_adapter, scsi_adapter, dti_adapter,
  58.     multifunc_adapter, dsk_controller, tp_controller, cdrom_controller,
  59.     worm_controller, serial_controller, net_controller, disp_controller,
  60.     parallel_controller, ptr_controller, kbd_controller, audio_controller,
  61.     misc_controller, disk_peripheral, flpy_peripheral, tp_peripheral,
  62.     modem_peripheral, monitor_peripheral, printer_peripheral,
  63.     ptr_peripheral, kbd_peripheral, term_peripheral, line_peripheral,
  64.     net_peripheral, misc_peripheral, anon
  65. };
  66.  
  67. enum linux_identifier {
  68.     bogus, ronly, removable, consin, consout, input, output
  69. };
  70.  
  71. /* A prom device tree component. */
  72. struct linux_component {
  73.     enum linux_devclass     class;   /* node class */
  74.     enum linux_devtypes     type;    /* node type */
  75.     enum linux_identifier   iflags;  /* node flags */
  76.     unsigned short          vers;    /* node version */
  77.     unsigned short          rev;     /* node revision */
  78.     unsigned long           key;     /* completely magic */
  79.     unsigned long           amask;   /* XXX affinity mask??? */
  80.     unsigned long           cdsize;  /* size of configuration data */
  81.     unsigned long           ilen;    /* length of string identifier */
  82.     char                   *iname;   /* string identifier */
  83. };
  84. typedef struct linux_component pcomponent;
  85.  
  86. struct linux_sysid {
  87.     char vend[8], prod[8];
  88. };
  89.  
  90. /* ARCS prom memory descriptors. */
  91. enum linux_memtypes {
  92.     eblock,  /* exception block */
  93.     rvpage,  /* ARCS romvec page */
  94.     fcontig, /* Contiguous and free */
  95.     free,    /* Generic free memory */
  96.     bmem,    /* Borken memory, don't use */
  97.     prog,    /* A loaded program resides here */
  98.     atmp,    /* ARCS temporary storage area, wish Sparc OpenBoot told this */
  99.     aperm,   /* ARCS permanent storage... */
  100. };
  101.  
  102. struct linux_mdesc {
  103.     enum linux_memtypes type;
  104.     unsigned long base;
  105.     unsigned long pages;
  106. };
  107.  
  108. /* Time of day descriptor. */
  109. struct linux_tinfo {
  110.     unsigned short yr;
  111.     unsigned short mnth;
  112.     unsigned short day;
  113.     unsigned short hr;
  114.     unsigned short min;
  115.     unsigned short sec;
  116.     unsigned short msec;
  117. };
  118.  
  119. /* ARCS virtual dirents. */
  120. struct linux_vdirent {
  121.     unsigned long namelen;
  122.     unsigned char attr;
  123.     char fname[32]; /* XXX imperical, should be a define */
  124. };
  125.  
  126. /* Other stuff for files. */
  127. enum linux_omode {
  128.     rdonly, wronly, rdwr, wronly_creat, rdwr_creat,
  129.     wronly_ssede, rdwr_ssede, dirent, dirent_creat
  130. };
  131.  
  132. enum linux_seekmode {
  133.     absolute, relative
  134. };
  135.  
  136. enum linux_mountops {
  137.     media_load, media_unload
  138. };
  139.  
  140. /* This prom has a bolixed design. */
  141. struct linux_bigint {
  142. #ifdef __MIPSEL__
  143.     unsigned long lo;
  144.     long hi;
  145. #else /* !(__MIPSEL__) */
  146.     long hi;
  147.     unsigned long lo;
  148. #endif
  149. };
  150.  
  151. struct linux_finfo {
  152.     struct linux_bigint   begin;
  153.     struct linux_bigint   end;
  154.     struct linux_bigint   cur;
  155.     enum linux_devtypes dtype;
  156.     unsigned long         namelen;
  157.     unsigned char         attr;
  158.     char                  name[32]; /* XXX imperical, should be define */
  159. };
  160.  
  161. struct linux_romvec {
  162.     /* Load an executable image. */
  163.     long (*load)(char *file, unsigned long end,
  164.              unsigned long *start_pc,
  165.              unsigned long *end_addr);
  166.  
  167.     /* Invoke a standalong image. */
  168.     long (*invoke)(unsigned long startpc, unsigned long sp,
  169.                long argc, char **argv, char **envp);
  170.  
  171.     /* Load and begin execution of a standalong image. */
  172.     long (*exec)(char *file, long argc, char **argv, char **envp);
  173.  
  174.     void (*halt)(void) __attribute__((noreturn));     /* Halt the machine. */
  175.     void (*pdown)(void) __attribute__((noreturn));    /* Power down the machine. */
  176.     void (*restart)(void) __attribute__((noreturn));  /* XXX soft reset??? */
  177.     void (*reboot)(void) __attribute__((noreturn));   /* Reboot the machine. */
  178.     void (*imode)(void) __attribute__((noreturn));    /* Enter PROM interactive mode. */
  179.     int _unused1; /* padding */
  180.  
  181.     /* PROM device tree interface. */
  182.     pcomponent *(*next_component)(pcomponent *this);
  183.     pcomponent *(*child_component)(pcomponent *this);
  184.     pcomponent *(*parent_component)(pcomponent *this);
  185.     long (*component_data)(void *opaque_data, pcomponent *this);
  186.     pcomponent *(*child_add)(pcomponent *this,
  187.                  pcomponent *tmp,
  188.                  void *opaque_data);
  189.     long (*comp_del)(pcomponent *this);
  190.     pcomponent *(*component_by_path)(char *file);
  191.  
  192.     /* Misc. stuff. */
  193.     long (*cfg_save)(void);
  194.     struct linux_sysid *(*get_sysid)(void);
  195.  
  196.     /* Probing for memory. */
  197.     struct linux_mdesc *(*get_mdesc)(struct linux_mdesc *curr);
  198.     long _unused2; /* padding */
  199.  
  200.     struct linux_tinfo *(*get_tinfo)(void);
  201.     unsigned long (*get_rtime)(void);
  202.  
  203.     /* File type operations. */
  204.     long (*get_vdirent)(unsigned long fd, struct linux_vdirent *entry,
  205.                 unsigned long num, unsigned long *count);
  206.     long (*open)(char *file, enum linux_omode mode, unsigned long *fd);
  207.     long (*close)(unsigned long fd);
  208.     long (*read)(unsigned long fd, void *buffer, unsigned long num,
  209.              unsigned long *count);
  210.     long (*get_rstatus)(unsigned long fd);
  211.     long (*write)(unsigned long fd, void *buffer, unsigned long num,
  212.               unsigned long *count);
  213.     long (*seek)(unsigned long fd, struct linux_bigint *offset,
  214.              enum linux_seekmode smode);
  215.     long (*mount)(char *file, enum linux_mountops op);
  216.  
  217.     /* Dealing with firmware environment variables. */
  218.     char *(*get_evar)(char *name);
  219.     long (*set_evar)(char *name, char *value);
  220.  
  221.     long (*get_finfo)(unsigned long fd, struct linux_finfo *buf);
  222.     long (*set_finfo)(unsigned long fd, unsigned long flags,
  223.               unsigned long mask);
  224.  
  225.     /* Miscellaneous. */
  226.     void (*cache_flush)(void);
  227. };
  228.  
  229. /* The SGI ARCS parameter block is in a fixed location for standalone
  230.  * programs to access PROM facilities easily.
  231.  */
  232. struct linux_promblock {
  233.     long                 magic;       /* magic cookie */
  234. #define PROMBLOCK_MAGIC      0x53435241
  235.  
  236.     unsigned long        len;          /* length of parm block */
  237.     unsigned short       ver;          /* ARCS firmware version */
  238.     unsigned short       rev;          /* ARCS firmware revision */
  239.     long                *rs_block;     /* Restart block. */
  240.     long                *dbg_block;    /* Debug block. */
  241.     long                *gevect;       /* XXX General vector??? */
  242.     long                *utlbvect;     /* XXX UTLB vector??? */
  243.     unsigned long        rveclen;      /* Size of romvec struct. */
  244.     struct linux_romvec *romvec;       /* Function interface. */
  245.     unsigned long        pveclen;      /* Length of private vector. */
  246.     long                *pvector;      /* Private vector. */
  247.     long                 adap_cnt;     /* Adapter count. */
  248.     long                 adap_typ0;    /* First adapter type. */
  249.     long                 adap_vcnt0;   /* Adapter 0 vector count. */
  250.     long                *adap_vector;  /* Adapter 0 vector ptr. */
  251.     long                 adap_typ1;    /* Second adapter type. */
  252.     long                 adap_vcnt1;   /* Adapter 1 vector count. */
  253.     long                *adap_vector1; /* Adapter 1 vector ptr. */
  254.     /* More adapter vectors go here... */
  255. };
  256.  
  257. #define PROMBLOCK ((struct linux_promblock *)0xA0001000UL)
  258. #define ROMVECTOR ((PROMBLOCK)->romvec)
  259.  
  260. /* Cache layout parameter block. */
  261. union linux_cache_key {
  262.     struct param {
  263. #ifdef __MIPSEL__
  264.         unsigned short size;
  265.         unsigned char lsize;
  266.         unsigned char bsize;
  267. #else /* !(__MIPSEL__) */
  268.         unsigned char bsize;
  269.         unsigned char lsize;
  270.         unsigned short size;
  271. #endif
  272.     } info;
  273.     unsigned long allinfo;
  274. };
  275.  
  276. /* Configuration data. */
  277. struct linux_cdata {
  278.     char *name;
  279.     int mlen;
  280.     enum linux_devtypes type;
  281. };
  282.  
  283. /* Common SGI ARCS firmware file descriptors. */
  284. #define SGIPROM_STDIN     0
  285. #define SGIPROM_STDOUT    1
  286.  
  287. /* Common SGI ARCS firmware file types. */
  288. #define SGIPROM_ROFILE    0x01  /* read-only file */
  289. #define SGIPROM_HFILE     0x02  /* hidden file */
  290. #define SGIPROM_SFILE     0x04  /* System file */
  291. #define SGIPROM_AFILE     0x08  /* Archive file */
  292. #define SGIPROM_DFILE     0x10  /* Directory file */
  293. #define SGIPROM_DELFILE   0x20  /* Deleted file */
  294.  
  295. /* SGI ARCS boot record information. */
  296. struct sgi_partition {
  297.     unsigned char flag;
  298. #define SGIPART_UNUSED 0x00
  299. #define SGIPART_ACTIVE 0x80
  300.  
  301.     unsigned char shead, ssect, scyl; /* unused */
  302.     unsigned char systype; /* OS type, Irix or NT */
  303.     unsigned char ehead, esect, ecyl; /* unused */
  304.     unsigned char rsect0, rsect1, rsect2, rsect3;
  305.     unsigned char tsect0, tsect1, tsect2, tsect3;
  306. };
  307.  
  308. #define SGIBBLOCK_MAGIC   0xaa55
  309. #define SGIBBLOCK_MAXPART 0x0004
  310.  
  311. struct sgi_bootblock {
  312.     unsigned char _unused[446];
  313.     struct sgi_partition partitions[SGIBBLOCK_MAXPART];
  314.     unsigned short magic;
  315. };
  316.  
  317. /* BIOS parameter block. */
  318. struct sgi_bparm_block {
  319.     unsigned short bytes_sect;    /* bytes per sector */
  320.     unsigned char  sect_clust;    /* sectors per cluster */
  321.     unsigned short sect_resv;     /* reserved sectors */
  322.     unsigned char  nfats;         /* # of allocation tables */
  323.     unsigned short nroot_dirents; /* # of root directory entries */
  324.     unsigned short sect_volume;   /* sectors in volume */
  325.     unsigned char  media_type;    /* media descriptor */
  326.     unsigned short sect_fat;      /* sectors per allocation table */
  327.     unsigned short sect_track;    /* sectors per track */
  328.     unsigned short nheads;        /* # of heads */
  329.     unsigned short nhsects;       /* # of hidden sectors */
  330. };
  331.  
  332. struct sgi_bsector {
  333.     unsigned char   jmpinfo[3];
  334.     unsigned char   manuf_name[8];
  335.     struct sgi_bparm_block info;
  336. };
  337.  
  338. /* Debugging block used with SGI symmon symbolic debugger. */
  339. #define SMB_DEBUG_MAGIC   0xfeeddead
  340. struct linux_smonblock {
  341.     unsigned long   magic;
  342.     void            (*handler)(void);  /* Breakpoint routine. */
  343.     unsigned long   dtable_base;       /* Base addr of dbg table. */
  344.     int             (*printf)(const char *fmt, ...);
  345.     unsigned long   btable_base;       /* Breakpoint table. */
  346.     unsigned long   mpflushreqs;       /* SMP cache flush request list. */
  347.     unsigned long   ntab;              /* Name table. */
  348.     unsigned long   stab;              /* Symbol table. */
  349.     int             smax;              /* Max # of symbols. */
  350. };
  351.  
  352. #endif /* !(_MIPS_SGIARCS_H) */
  353.